package com.spareparts.protocol;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.spareparts.entyties.QuYu;

import cm.framework.protocol.BaseJSONRsponse;

public class QuYuResponse extends BaseJSONRsponse 
{
	public List<QuYu> mQuYu = new ArrayList<QuYu>();
	
	@Override
	protected boolean extractBody(JSONObject arg0) 
	{
		try 
		{
			JSONArray dataJsonArray = arg0.getJSONArray("res");
			if ( dataJsonArray != null && dataJsonArray.length()>0)
			{
				QuYu oQuYu1 = new QuYu();
				oQuYu1.id = "";
				oQuYu1.name = "";
				oQuYu1.pid = "";
				oQuYu1.sort = "";
				mQuYu.add(oQuYu1);
				for(int i=0;i<dataJsonArray.length();i++)
				{
					QuYu oQuYu = new QuYu();
					JSONObject jsonObj = dataJsonArray.getJSONObject(i);
					oQuYu.id = jsonObj.getString("id");
					oQuYu.name = jsonObj.getString("name");
					oQuYu.pid = jsonObj.getString("pid");
					oQuYu.sort = jsonObj.getString("sort");
					mQuYu.add(oQuYu);
				}
			}
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
		return true;
	}

}
